const treeData = require("./treeData")

//深度优先递归遍历树
function traverseTreeByDepth(node){
    if(!node){
        return
    }
    console.log("node:",node.value)
    node.children.length && node.children.forEach((nodeItem)=>{
        if(nodeItem.children.length > 0){
            traverseTreeByDepth(nodeItem)
        }else{
            console.log("node:",nodeItem.value)
        }
    })
}

function testTraverseTreeByDepth(){
    const tree = treeData.getTree()
    traverseTreeByDepth(tree)
}
testTraverseTreeByDepth()